
print "This is a script for correcting DC abox.";

$aboxfile = "dpreview.abox";
$outputfile = "dpreview_new.abox";
open (IN, "< $aboxfile") || die "No abox file: $aboxfile exists!";
open (OUT, "> $outputfile") || die "Cannot create $outputfile"; 
	$globe = 0;
	@lines = <IN>;
	$count = 0; ###false;
foreach $_ (@lines){
	##chomp($_);
	if($_ =~ /^\s+$/){
		next;
	}
	if($_ =~ /^(.+) digicam(\d+) (.+)$/){
		$newline = $_;
		$number = $2;
		$pre = $1, $post = $3;
		$globe ++;
		if($number == 0){
			$count ++;
		}
		if($count>1){
			## find another digicam0, replace it.
			$newline = $pre . " digicam$globe " . $post."\n";
		}
		print OUT $newline;
	}else{
		print "ERROR! Not a valid line.\n";
	}
}


close (IN);
close (OUT);
